/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package at.ofai.gate.riplugin2;

import gate.Resource;
import gate.creole.ResourceInstantiationException;
import gate.creole.metadata.CreoleResource;
import gate.event.CreoleListener;
import gate.gui.ActionsPublisher;
import java.io.File;

/**
 * A LR representing a SV random index. A SV random index is backed by
 * a directory that contains a Lucene index and the files for a positional
 * or non-positional SV random index. However, a LR can also just represent
 * an empty directory which will be the destination of a random index that
 * will still be created.
 * 
 * @author Johann Petrak
 */
@CreoleResource(
    name = "RIIndexSVPositionalLR2",
    //interfaceName = "",
    comment = "RI SemanticVectors Positional Index",
    icon = "ontology"
    //helpURL = "http://gate.ac.uk/userguide/sec:ontologies:ontoplugin:owlim"
    )
public class RIIndexSVPositionalLR
  extends RIIndexSVLR
  implements ActionsPublisher, CreoleListener{

  @Override
  public Resource init() throws ResourceInstantiationException {
    super.init();
    // check the directory and see if we have index files in there.
    // set the internal flags accordingly.
    File directory = gate.util.Files.fileFromURL(directoryURL);
    if(!directory.exists()) {
      throw new ResourceInstantiationException("No directory exists with URL: "+directoryURL);
    }
    svTermIndex = new File(directory,"postermvectors.bin");
    svDocumentIndex = new File(directory,"posdocvectors.bin");
    return this;
  }


}
